var dataArr = [];
// 学校第一个实例
function schoolGradationYears() {
    table.render({
        elem: '#schoolDataTables1'
        , url: '/oauthplatform/statisticalSchool/schoolGradationYears' //数据接口,
        , parseData: function (res) { //res 即为原始返回的数据
            return {
                "code": 0, //解析接口状态
                "msg": "", //解析提示文本
                "count": res.size, //解析数据长度
                "data": res //解析数据列表
            };
        }
        , page: false
        , even: true
        , cols: [[ //表头
            {type: 'numbers', title: '序号',  fixed: 'left', width: '10%'} ,
            {field: 'year', title: '年',  sort: true, fixed: 'left', width: '25%'}
            , {field: 'secondaryVocational',  sort: true, title: '中职', width: '20%'}
            , {field: 'higherVocational',  sort: true, title: '高职', width: '20%'}
            , {field: 'sum',  sort: true, title: '总数', width: '25%'}
        ]]
        , done: function (res, curr, count) {
            // 数据
            var dataArr = res.data;
            var sourceData = [];

            var type = ["type"];
            var zhong = ["中职"];
            var gao = ["高职"];
            var sum = ["合计"];
            dataArr.forEach((item, index) => {
                type.push(item.year);
                zhong.push(item.secondaryVocational);
                gao.push(item.higherVocational);
                sum.push(item.sum);
            })
            sourceData = [type, zhong, gao, sum];
            optDataBarGraph('schoolReport1', sourceData, '学校数量（所）', function (params) {
                return params[0].data[0] + '年<br/>中职：' + params[0].data[1] + '&nbsp;所<br/>高职：' + params[0].data[2] + '&nbsp;所<br/>合计：' + params[0].data[3] + '&nbsp;所'
            });

            let areaName = "";
            if (dataArr.length != 0 && dataArr[0].areaName != "河南省") {
                areaName = dataArr[0].areaName;
            } else {
                // 有可能是查询某个市，但是没数据
                var areaSelect = $("#schoolGradationYears #areaId option:selected").text();
                if (areaSelect != "请选择市级") {
                    areaName = areaSelect;
                }
            }
            // 某个地市
            $("#alwaysAreaName").text(areaName);
        }
    });

    dateRange("schoolGradationYears");

}

// 学校层次统计（按地市）
var gradationAreaYear;  // 当前年度
function schoolGradationArea() {
    table.render({
        elem: '#schoolDataTablesArea'
        , url: '/oauthplatform/statisticalSchool/schoolGradationArea' //数据接口,
        , parseData: function (res) { //res 即为原始返回的数据
            return {
                "code": 0, //解析接口状态
                "msg": "", //解析提示文本
                "count": res.size, //解析数据长度
                "data": res //解析数据列表
            };
        }
        , page: false
        , even: true
        , cols: [[ //表头
            {type: 'numbers', title: '序号',  fixed: 'left', width: '10%'} ,
            {field: 'areaName', title: '地市',  sort: true, fixed: 'left', width: '25%'}
            , {field: 'secondaryVocational',  sort: true, title: '中职', width: '20%'}
            , {field: 'higherVocational',  sort: true, title: '高职', width: '20%'}
            , {field: 'sum',  sort: true, title: '总数', width: '25%'}
        ]]
        , done: function (res, curr, count) {
            // 数据
            var dataArr = res.data;
            var sourceData = [];
            // 提示信息
            var type = [];
            // 数据列
            var zhong = [];
            // 数据列
            var gao = [];
            // 数据列
            var sum = ["合计"];

            var trends = [];
            dataArr.forEach((item, index) => {
                type.push(item.areaName);
                zhong.push(item.secondaryVocational);
                gao.push(item.higherVocational);
                sum.push(item.sum);
                trends.push([item.secondaryTrend,item.higherTrend,item.trend]);
            })
            sourceData = {"type": type.reverse(), "中职": zhong.reverse(), "高职": gao.reverse(),trends:trends.reverse()};
            // optData(sourceData);
            optDataAcrossBarGraph('schoolReportArea', sourceData, '学校数量（所）', '所');

            let year = "";
            if (dataArr.length != 0 && dataArr[0].year != null && dataArr[0].year != "") {
                year = dataArr[0].year;
                gradationAreaYear = dataArr[0].year;
            } else {
                // 有可能是查询某个市，但是没数据
                var yearSelect = $("#schoolGradationArea #year option:selected").text();
                if (yearSelect != "全部") {
                    year = yearSelect;
                }
            }
            // 某个地市
            $("#alwaysYear").text(year != "" ? "(" + year + ")" : year);

        }

    });
}